Settings
Settings()The configuration settings for the FloodAdapt database and integrator.
Precedence is as follows: user arguments > environment variables > defaults in this class. When loading is done, the settings are validated and the environment variables are updated with the loaded values.
If any required settings are missing or invalid, a ValidationError is raised.
Usage
from flood_adapt.config.settings import Settings
One of the following:
Load settings from environment variables, if no environment variables are set, use defaults defined in the class:
settings = Settings()Load settings from a .toml file, overwriting any environment variables set:
settings = Settings.read(toml_path: Path)Load settings from keyword arguments, overwriting any environment variables:
settings = Settings(DATABASE_ROOT="path/to/database", DATABASE_NAME="database_name")
Attributes
database_name : (str | None,defaultis None)-
The name of the database. Alias:
DATABASE_NAME(environment variable). database_root : (Path | None,defaultis None)-
The root directory of the database. Alias:
DATABASE_ROOT(environment variable). delete_crashed_runs : (bool,defaultis False)-
Whether to delete crashed/corrupted runs immediately after they are detected. Alias:
DELETE_CRASHED_RUNS(environment variable). validate_allowed_forcings : (bool,defaultis False)-
Whether to validate the forcing types and sources against the allowed forcings in the event model. Alias:
VALIDATE_ALLOWED_FORCINGS(environment variable). use_binaries : (bool,defaultis False)-
Whether to validate the existence of the paths to the SFINCS and FIAT binaries. Alias:
USE_BINARIES(environment variable). sfincs_bin_path : (Path | None,defaultis None)-
The path to the SFINCS binary. Alias:
SFINCS_BIN_PATH(environment variable). sfincs_version : str, default is '2.2.1-alpha col d'Eze'-
The expected version of the SFINCS binary. Alias:
SFINCS_VERSION(environment variable). fiat_bin_path : (Path | None,defaultis None)-
The path to the FIAT binary. Alias:
FIAT_BIN_PATH(environment variable). fiat_version : (str,defaultis '0.2.1')-
The expected version of the FIAT binary. Alias:
FIAT_VERSION(environment variable). log_level : (str,defaultisINFO)-
The logging level for the application. Alias:
LOG_LEVEL(environment variable).
Properties
database_path : Path The full path to the database.
Raises
:ValidationError-
If required settings are missing or invalid.
Methods
| Name | Description |
|---|---|
| check_binary_versions | Check that the versions of the binaries in the config match those expected. |
| export_to_env | Export all settings to environment variables using the aliases as keys. |
| get_fiat_version | Get the version of the FIAT binary. |
| get_sfincs_version | Get the version of the SFINCS binary. |
| read | Parse the configuration file and return the parsed settings. |
| write | Write the configuration settings to a .toml file. |
check_binary_versions
Settings.check_binary_versions()Check that the versions of the binaries in the config match those expected.
export_to_env
Settings.export_to_env()Export all settings to environment variables using the aliases as keys.
get_fiat_version
Settings.get_fiat_version()Get the version of the FIAT binary.
Returns
: str-
The version of the FIAT binary
Expected FIAT output
FIAT 0.2.1, build 2025-02-24T16:19:19 UTC+0100 …
get_sfincs_version
Settings.get_sfincs_version()Get the version of the SFINCS binary.
Returns
: str-
The version of the SFINCS binary
Expected SFINCS output
———— Welcome to SFINCS ————
LOGO
Build-Revision: $Rev: v2.2.1-alpha col d’Eze Build-Date: $Date: 2025-06-02
—— Preparing model simulation ——– …
read
Settings.read(toml_path: Path)Parse the configuration file and return the parsed settings.
Parameters
toml_path : Path-
The path to the configuration file.
Returns
: Settings-
The parsed configuration settings.
Raises
:ValidationError-
If required configuration values are missing or if there is an error parsing the configuration file.
write
Settings.write(toml_path: Path)Write the configuration settings to a .toml file.
Parameters
toml_path : Path-
The path to the configuration file.
Returns
: None